import {Form, Input} from 'antd';
import React, {Component} from 'react';
import {reqSearchResume} from '../../api/index'

const {Search} = Input;

class Index extends Component {
    constructor(props) {
        super(props);
        this.state = {
            resume: [],
            count: 0
        };
    }

    //为第一次render()准备数据
    componentWillMount() {


    }

    //发异步ajax请求
    componentDidMount() {

    }

    getSearchResume = async (value) => {

        const result = await reqSearchResume(value)
        const count = result.data.count
        const resume = result.data.results
        const data = []
        resume.map(item => data.push({
            row1: {
                name: item.name,
                gender: item.gender,
                age: item.age,
                education: item.education,
            },
            row2:{
                exp_postion:item.exp_postion,
                exp_trade: item.exp_trade,
                exp_salary: item.exp_salary,
            },
            row3:{
                now_postion: item.now_postion,
                now_trade:item.now_trade,
                worktime: item.worktime,
            },
            row4:{
                status:item.status,
                rej_trade: item.rej_trade,
                rej_postion: item.rej_postion,
            },
            row5:{
                location:item.location,
                city: item.city,
            },
            key: item.id,
            employee: item.employee,
        }))
        this.setState({
            resume: data,
            count: count
        })
        const keyword=value
        this.props.public.getSearchResult(keyword, this.state.resume, this.state.count)
    }

    render() {
        return (
            <div>
                <Search placeholder="姓名、年龄、性别、岗位、行业、期望薪资搜索" onSearch={value => this.getSearchResume(value)}
                        enterButton/>
            </div>
        )
    }
}

const WrapIndex = Form.create()(Index)
export default WrapIndex
